//
//  UTTOTP.m
//  OTPGenerator
//
//  Created by 武探 on 2017/3/30.
//  Copyright © 2017年 wutan. All rights reserved.
//

#import "UTTOTP.h"
#import "UTOTPConfiguration.h"

@implementation UTTOTP

-(NSString*)generateOTP {
    return [self generateWithDate:[NSDate date]];
}

-(NSString*)generateWithDate:(NSDate*)date {
    
    UTOTPConfiguration *config = self.configuration;
    
    NSTimeInterval seconds = [date timeIntervalSince1970];
    uint64_t counter = (uint64_t) (seconds / config.defaultInterval);
    
    return [super generateOTPForCounter:counter];
}

@end
